/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Prestahop_retrievement;

import com.insa.a1.hibernate.ps.PsCartProduct;
import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

/**
 *
 * @author strokyl
 */
@Entity
public class CartProduct implements Serializable {
    private int quantity;

    @EmbeddedId
    @Cascade(CascadeType.ALL)
    private CartProductPK cartProductPK;

    public CartProduct() {
    }

    CartProduct(PsCartProduct psCartProduct, Cart cart) {
        this.quantity = psCartProduct.getQuantity();
        this.cartProductPK = new CartProductPK(cart, psCartProduct.getPsCartProductPK().getProduct().getAssociatedProduct());
        psCartProduct.getPsCartProductPK().getProduct().getAssociatedProduct().getCartProducts().add(this);
    }
    
    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public CartProductPK getCartProductPK() {
        return cartProductPK;
    }

    public void setCartProductPK(CartProductPK cartProductPK) {
        this.cartProductPK = cartProductPK;
    }

}
